<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Door_control_dll: Door_control_dll.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Door_control_dll
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">Door_control_dll.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_door__control__dll_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00026"></a>00026 <span class="preprocessor">#ifndef DOOR_CONTROL_DLL_H</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span><span class="preprocessor">#define DOOR_CONTROL_DLL_H</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#include &lt;windows.h&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;time.h&gt;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00033"></a>00033 <span class="comment">//#include &lt;boost/thread/thread.hpp&gt;</span>
<a name="l00034"></a>00034 <span class="comment">//#include &lt;boost/thread/mutex.hpp&gt;</span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;boost/interprocess/sync/interprocess_mutex.hpp&gt;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;boost/interprocess/sync/scoped_lock.hpp&gt;</span>
<a name="l00038"></a>00038 <span class="comment">//#include &lt;boost/thread/locks.hpp&gt;</span>
<a name="l00039"></a>00039 <span class="comment">//#include &lt;wininet.h&gt;</span>
<a name="l00040"></a>00040 <span class="comment">//#pragma comment(lib,&quot;Wininet.lib&quot;)</span>
<a name="l00041"></a>00041 <span class="comment">//#include &quot;curl&quot;</span>
<a name="l00042"></a>00042 <span class="comment">//#include &lt;winsock2.h&gt;</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include &quot;ftdi2xx.h&quot;</span>
<a name="l00044"></a>00044 
<a name="l00045"></a>00045 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span>
<a name="l00047"></a>00047 {
<a name="l00048"></a>00048 <span class="preprocessor">#endif</span>
<a name="l00049"></a>00049 <span class="preprocessor"></span>__declspec(dllexport) BOOL WINAPI __stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
<a name="l00060"></a>00060 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_init(<span class="keywordtype">void</span>);
<a name="l00073"></a>00073 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_dev_if_mode(<span class="keywordtype">int</span> mode);
<a name="l00074"></a>00074 
<a name="l00075"></a>00075 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall set_read_buff_after_writing(<span class="keywordtype">int</span> inp_val);
<a name="l00083"></a>00083 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_ser_set_name(const <span class="keywordtype">char</span> *ser_port_name);
<a name="l00091"></a>00091 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_ser_set_num(<span class="keywordtype">int</span> port_no);
<a name="l00123"></a>00123 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_dev_open(<span class="keywordtype">void</span>);
<a name="l00144"></a>00144 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_ft_get_driver_version(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>* ft_drv_ver);
<a name="l00163"></a>00163 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_ft_get_library_version(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>* ft_lib_ver);
<a name="l00173"></a>00173 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_ser_open(<span class="keywordtype">void</span>);
<a name="l00187"></a>00187 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_set_brd_ver(<span class="keywordtype">char</span> board_version);
<a name="l00200"></a>00200 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_get_brd_ver(<span class="keywordtype">char</span> * board_version);
<a name="l00216"></a>00216 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_set_ser_no(<span class="keywordtype">char</span> * buf);
<a name="l00233"></a>00233 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_get_ser_no(<span class="keywordtype">char</span> * buf, <span class="keywordtype">int</span> buf_len);
<a name="l00254"></a>00254 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_get_fwv(<span class="keywordtype">char</span> * buf, <span class="keywordtype">int</span> buf_len);
<a name="l00255"></a>00255 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_ser_set_baud(<span class="keywordtype">int</span> baud);
<a name="l00256"></a>00256 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_ser_get_baud(<span class="keywordtype">void</span>);
<a name="l00257"></a>00257 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_ser_read_buf(<span class="keywordtype">char</span> * buf, <span class="keywordtype">int</span> * n_recv, <span class="keywordtype">int</span> size);
<a name="l00258"></a>00258 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_leds_set(<span class="keywordtype">int</span> led_No, <span class="keywordtype">int</span> led_state);
<a name="l00259"></a>00259 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_get_sum(<span class="keywordtype">int</span> a, <span class="keywordtype">int</span> b, <span class="keywordtype">int</span> * sum);
<a name="l00271"></a>00271 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_lock_set(<span class="keywordtype">int</span> state);
<a name="l00279"></a>00279 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_inps_get(<span class="keywordtype">void</span>);
<a name="l00288"></a>00288 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_modem_reset(<span class="keywordtype">void</span>);
<a name="l00289"></a>00289 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_ser_close(<span class="keywordtype">void</span>);
<a name="l00297"></a>00297 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_finish(<span class="keywordtype">void</span>);
<a name="l00298"></a>00298 
<a name="l00299"></a>00299 __declspec(dllexport) <span class="keywordtype">int</span> __stdcall door_control_d2xx_dll_open(<span class="keywordtype">void</span>);
<a name="l00300"></a>00300 
<a name="l00301"></a>00301 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00302"></a>00302 <span class="preprocessor"></span>}
<a name="l00303"></a>00303 <span class="preprocessor">#endif</span>
<a name="l00304"></a>00304 <span class="preprocessor"></span>
<a name="l00305"></a>00305 <span class="keyword">extern</span> HINSTANCE dll_handle;
<a name="l00306"></a><a class="code" href="classdoor__control__device.html">00306</a> <span class="keyword">class </span><a class="code" href="classdoor__control__device.html">door_control_device</a> {
<a name="l00307"></a>00307 <span class="keyword">private</span>:
<a name="l00308"></a>00308     <span class="comment">// variables to store serial port data</span>
<a name="l00309"></a>00309     DCB dcb_curr, dcb_prev; <span class="comment">// serial port structures for current and previous states</span>
<a name="l00310"></a>00310     COMMTIMEOUTS CommTimeOuts_curr, CommTimeOuts_prev;
<a name="l00311"></a>00311     <span class="comment">//</span>
<a name="l00312"></a>00312     <span class="keywordtype">int</span> read_buff_after_writing;    <span class="comment">// 1 - to read all data from serial after writing</span>
<a name="l00313"></a>00313 <span class="keyword">public</span>:
<a name="l00314"></a>00314     <span class="keywordtype">int</span> baud;   <span class="comment">// Serial port baudrate</span>
<a name="l00315"></a>00315     HANDLE hPort;   <span class="comment">// Serial port file hadle</span>
<a name="l00316"></a>00316     <span class="keywordtype">char</span> ser_port_name[32]; <span class="comment">// Serial port name</span>
<a name="l00317"></a>00317     <span class="keywordtype">int</span> serial_is_opened;
<a name="l00318"></a>00318     boost::interprocess::interprocess_mutex ser_port_mutex;
<a name="l00319"></a>00319     FT_HANDLE ft_handle;    <span class="comment">// handler for ftdi device</span>
<a name="l00320"></a>00320     FT_STATUS ft_status;    <span class="comment">// variable to store returned value from ftdi functions</span>
<a name="l00321"></a>00321     HMODULE h_d2xx_dll;
<a name="l00322"></a>00322     <span class="keywordtype">int</span> d2xx_dll_is_loaded; <span class="comment">// 1 - dll is loaded, 0 - dll not loaded</span>
<a name="l00323"></a>00323     <span class="keywordtype">int</span> d2xx_opened;
<a name="l00324"></a>00324     <span class="keywordtype">int</span> ft_handle_opened;
<a name="l00325"></a>00325     <span class="keywordtype">int</span> dev_interface_mode; <span class="comment">// 1 - VCP mode, 2 - d2xx mode</span>
<a name="l00326"></a>00326     <span class="keywordtype">char</span> fwv_str[127];  <span class="comment">// Door_controller firmware version stored here</span>
<a name="l00327"></a>00327     <span class="keywordtype">char</span> inps_state_prev;   <span class="comment">// Inputs previous state. Used for logging changes of inputs only</span>
<a name="l00328"></a>00328     <span class="keywordtype">char</span> inps_state_pres;   <span class="comment">// Inputs current state</span>
<a name="l00329"></a>00329     <span class="keywordtype">char</span> lock_state_pres;   <span class="comment">// Lock current state</span>
<a name="l00330"></a>00330     <span class="keywordtype">char</span> lock_state_prev;   <span class="comment">// Lock previous state</span>
<a name="l00331"></a>00331     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> tries_n;  <span class="comment">// How many times to retry to perform command</span>
<a name="l00332"></a>00332     <span class="keywordtype">char</span> log_file_name[255];    <span class="comment">// Log file name</span>
<a name="l00333"></a>00333     <span class="keywordtype">char</span> log_file_path[255];
<a name="l00334"></a>00334     FILE * log_file_ptr;    <span class="comment">// Log file pointer</span>
<a name="l00335"></a>00335     <span class="keywordtype">int</span> log_file_year_day_prev;     <span class="comment">// Log file previous day since January 1, for logging one file per day</span>
<a name="l00336"></a>00336     <span class="keywordtype">int</span> log_file_year_day_pres;     <span class="comment">// Log file current day since January 1</span>
<a name="l00337"></a>00337     <span class="keywordtype">int</span> dbg_inps_r_counter;         <span class="comment">// Debug, number of calling function inps_r</span>
<a name="l00338"></a>00338     <span class="keywordtype">int</span> log_add_str(<span class="keywordtype">char</span> * log_str);    <span class="comment">// Function to write log string. Adds data in the beginning an and CR in the end of string.</span>
<a name="l00339"></a>00339     <a class="code" href="classdoor__control__device.html">door_control_device</a>(<span class="keywordtype">void</span>);
<a name="l00340"></a>00340     <span class="keywordtype">int</span> set_read_buff_after_writing(<span class="keywordtype">int</span> inp_val);
<a name="l00341"></a>00341     <span class="keywordtype">int</span> open_ser(<span class="keywordtype">void</span>); <span class="comment">// open serial port</span>
<a name="l00342"></a>00342     <span class="keywordtype">int</span> open_d2xx_dll(<span class="keywordtype">void</span>);    <span class="comment">//load ftd2xx dll, return 0 if successfull, -1 if error</span>
<a name="l00343"></a>00343     <span class="keywordtype">int</span> open_d2xx(<span class="keywordtype">void</span>);
<a name="l00344"></a>00344     <span class="keywordtype">int</span> ft_get_driver_version(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>* ft_driver_ver);
<a name="l00345"></a>00345     <span class="keywordtype">int</span> ft_get_library_version(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>* ft_library_ver);
<a name="l00346"></a>00346     <span class="keywordtype">int</span> set_brd_ver(<span class="keywordtype">char</span> board_version);
<a name="l00347"></a>00347     <span class="keywordtype">int</span> get_brd_ver(<span class="keywordtype">char</span> * board_version);
<a name="l00348"></a>00348     <span class="keywordtype">int</span> set_ser_no(<span class="keywordtype">char</span> * buf);
<a name="l00349"></a>00349     <span class="keywordtype">int</span> get_ser_no(<span class="keywordtype">char</span> * buf);
<a name="l00350"></a>00350     <span class="keywordtype">int</span> get_fwv(<span class="keywordtype">char</span> * buf);
<a name="l00351"></a>00351     <span class="keywordtype">int</span> set_baud(<span class="keywordtype">int</span> inp_baud);
<a name="l00352"></a>00352     <span class="keywordtype">int</span> get_baud(<span class="keywordtype">void</span>);
<a name="l00353"></a>00353     <span class="keywordtype">int</span> write_strz(<span class="keywordtype">char</span> * buf);
<a name="l00354"></a>00354     <span class="keywordtype">int</span> read_buf(<span class="keywordtype">char</span> * buf, <span class="keywordtype">int</span> * n_recv, <span class="keywordtype">int</span> size);
<a name="l00355"></a>00355     <span class="keywordtype">int</span> purge_buf(<span class="keywordtype">void</span>);
<a name="l00356"></a>00356     <span class="keywordtype">int</span> led_set(<span class="keywordtype">int</span> led_No, <span class="keywordtype">int</span> led_state);
<a name="l00357"></a>00357     <span class="keywordtype">int</span> get_sum(<span class="keywordtype">int</span> a, <span class="keywordtype">int</span> b, <span class="keywordtype">int</span> * sum);
<a name="l00358"></a>00358     <span class="keywordtype">int</span> lock_set(<span class="keywordtype">int</span> state);
<a name="l00359"></a>00359     <span class="keywordtype">int</span> inps_get(<span class="keywordtype">void</span>);
<a name="l00360"></a>00360     <span class="keywordtype">int</span> modem_reset(<span class="keywordtype">void</span>);
<a name="l00361"></a>00361     <span class="keywordtype">int</span> check_internet(<span class="keywordtype">void</span>);
<a name="l00362"></a>00362     <span class="keywordtype">int</span> close_ser(<span class="keywordtype">void</span>);
<a name="l00363"></a>00363     <span class="keywordtype">int</span> close(<span class="keywordtype">void</span>);
<a name="l00364"></a>00364     <span class="comment">//virtual ~ser_port();</span>
<a name="l00365"></a>00365     ~<a class="code" href="classdoor__control__device.html">door_control_device</a>();
<a name="l00366"></a>00366 };
<a name="l00367"></a>00367 
<a name="l00368"></a>00368 <span class="preprocessor">#endif </span><span class="comment">/* DOOR_CONTROL_DLL_H */</span>
</pre></div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated on Fri Feb 1 2013 14:57:24 for Door_control_dll by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>
